package olga.gorbatiuk.perdep.sorting.sort.impl;

import olga.gorbatiuk.perdep.sorting.sort.AbstractSort;

/**
 * @author Olga Gorbatiuk
 */
public class SelectionSort extends AbstractSort {

    /**
     * @see olga.gorbatiuk.perdep.sorting.sort.Sort#sort(int[])
     */
    @Override
    public void sort(int[] array) {
        for (int i = 0; i < array.length - 1; i++) {
            int min = array[i];
            for (int j = i + 1; j < array.length; j++) {
                if (array[j] < min) {
                    min = array[j];
                    swap(i, j, array);
                }
            }
        }
    }
}
